<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/11/8
 * Time: 10:12
 */

namespace Modules\Admin\Http\Controllers;

use Illuminate\Support\Facades\Redis;
use Illuminate\Support\Facades\Request;
use Modules\Admin\Service\RoadRescueService;

class RoadRescueController extends BaseController
{

    /**
     *  道路救援列表
     *  hinq 2019 11 07
     *
     **/
    public function index(){
        $arr_search = (array) Request::all();
        $arr_list = RoadRescueService::get_list( (array) $arr_search );
        echo_error($arr_list);
        return view('admin::roadRescue.index',$arr_list['data']);
    }

    /**
     *  添加道路救援视图
     *  hinq 2019 11 08
     *
     **/
    public function create(){
        return view('admin::roadRescue.create');
    }

    /**
     *  添加道路救援数据
     *  hinq 2019 11 08
     *
     **/
    public function store(){
        $arr_input = (array) Request::all();
        return RoadRescueService::add_one( (array) $arr_input );
    }

    /**
     *  编辑道路救援视图
     *  hinq 2019 11 08
     *
     **/
    public function edit(){
        $nId = (int) Request::get('id');
        $arr_info = RoadRescueService::get_one( (int) $nId );
        return view('admin::roadRescue.edit',['info'=>$arr_info]);
    }

    /**
     *  编辑道路救援数据
     *  hinq 2019 11 08
     *
     **/
    public function update(){
        $arr_input = (array) Request::all();
        return RoadRescueService::edit_one( (array) $arr_input );
    }

    /**
     *  删除道路救援数据
     *  hinq 2019 11 08
     *
     **/
    public function delete(){
        $nId = (array) Request::get('id');
        return RoadRescueService::delete_one( (int) $nId );
    }


    /**
     *  banner管理
     *  hinq 2019 11 08
     *
     **/
    public function banner(){
        $arr_search = (array) Request::all();
        $arr_search['type'] = 3;
        $arr_list = RoadRescueService::get_list_banner( (array) $arr_search );
        echo_error($arr_list);
        return view('admin::roadRescue.banner',$arr_list['data']);
    }

    /**
     *  添加banner视图
     *  hinq 2019 11 08
     *
     **/
    public function create_banner(){
        $arr_search = (array) Request::all();
        return view('admin::roadRescue.create_banner',['type'=>$arr_search['type']]);
    }

    /**
     *  添加banner数据
     *  hinq 2019 11 08
     *
     **/
    public function store_banner(){
        $arr_input = (array) Request::all();
        return RoadRescueService::store_banner( (array) $arr_input );
    }


    /**
     *  编辑banner数据视图
     *  hinq 2019 12 19
     *
     **/
    public function edit_banner(){
        $nId  = (int) Request::get('id');
        $arr_list = RoadRescueService::edit_banner( (int) $nId );
        return view('admin::roadRescue.edit_banner',['info'=> $arr_list['data'] ]);
    }

    /**
     *  编辑banner数据
     *  hinq 2019 12 19
     *
     **/
    public function update_banner(){
        $arr_input = (array) Request::all();
        return RoadRescueService::update_banner( (array) $arr_input );
    }

    /**
     *  删除指定的banner数据
     *  hinq 2019 12 20
     *
     **/
    public function delete_banner(){
        $nId  = (int) Request::get('id');
        return RoadRescueService::delete_banner( (int) $nId );
    }







}